<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>WebSocket</title>
</head>
<body>
<template>
    <div id="app">
        <input id="input"  type="text" @keyup.enter.native="Send" placeholder="聊天内容">
    </div>
</template>

<script>
    var ws = new WebSocket("ws://111.230.171.153:8083");
    ws.onopen =  ()=> {
        console.log("连接成功");
        ws.send("hello,thinkphp");
    };
    ws.onmessage =  (e)=> {

    };
    let text = document.querySelector('#input')

    function Send() {
        ws.send(text.value);
    }
</script>
</body>
</html>